package hu.szyrt.bug.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Validator {

	private final static String emailPattern = "^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@"
											 + "((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
											 + "[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
											 + "([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
											 + "[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
											 + "([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})";
	
	private final static String namePattern 	= "[a-zA-ZöüóőúéáűíÖÜÓŐÚÉÁŰÍß\\- ]+";
								//zipCodePattern 	= "[1-9]{1,}[0-9]{3,3}",
								//cityPattern 	= "[a-zA-ZöüóőúéáűíÖÜÓŐÚÉÁŰÍß\\-. ]+",
								//streetNoPattern = "[a-zA-ZöüóőúéáűíÖÜÓŐÚÉÁŰÍ0-9/\\-. ]+";


	public static boolean isValidPassword(String password){
		return !(password == null || password.length() < 5);
	}
	
	public static boolean isValidEmail(String email){
		if(email == null || email.length() == 0) return false;
		Matcher m = Pattern.compile(emailPattern).matcher(email);
		return m.matches();
	}
	
	public static boolean isValidName(String name){
		if(name == null || name.trim().length() < 5)
			return false;
		Matcher m = Pattern.compile(namePattern).matcher(name);
		return m.matches();
	}

	
}
